package c.c.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.bytedance.embedapplog.InitConfig;
import org.json.JSONException;
import org.json.JSONObject;

public class g2 {
    public final Context a;
    public final InitConfig b;
    public final SharedPreferences c;
    public final SharedPreferences d;
    public final SharedPreferences e;
    public volatile JSONObject f;
    public volatile JSONObject g;

    public g2(Context context, InitConfig initConfig) {
        this.a = context;
        this.b = initConfig;
        this.e = context.getSharedPreferences("embed_applog_stats", 0);
        this.c = context.getSharedPreferences("embed_header_custom", 0);
        this.d = context.getSharedPreferences("embed_last_sp_session", 0);
    }

    public int a() {
        return this.e.getInt("bav_monitor_rate", 0);
    }

    public boolean b() {
        if (this.b.getProcess() == 0) {
            this.b.setProcess(n0.a(this.a).contains(":") ^ 1);
        }
        if (this.b.getProcess() == 1) {
            return true;
        }
        return false;
    }

    public String c() {
        if (TextUtils.isEmpty(this.b.getAbVersion())) {
            return this.c.getString("ab_version", null);
        }
        return this.b.getAbVersion();
    }

    public JSONObject d() {
        JSONObject jSONObject = this.f;
        if (jSONObject == null) {
            synchronized (this) {
                try {
                    if (e()) {
                        jSONObject = new JSONObject(this.c.getString("ab_configure", ""));
                    }
                } catch (JSONException unused) {
                }
                if (jSONObject == null) {
                    jSONObject = new JSONObject();
                }
                this.f = jSONObject;
            }
        }
        return jSONObject;
    }

    public boolean e() {
        return this.e.getBoolean("bav_ab_config", false);
    }
}
